<template>
  <div class="login-container">
    <div class="login-content">
      <div class="login-left">
        <div class="login-title">
          <img src="@/assets/common/img_logo@2x.png" alt="">
        </div>
        <el-form
          ref="loginRef"
          :model="loginForm"
          :rules="loginRules"
          class="login-form"
          auto-complete="on"
          label-position="left"
        >
          <el-form-item prop="mobile">
            <div class="user">
              <div class="img">
                <img src="" alt="">
              </div>
              <div class="input">
                <el-input
                  ref="username"
                  v-model="loginForm.mobile"
                  placeholder="Username"
                  name="username"
                  type="text"
                  tabindex="1"
                  auto-complete="on"
                />
              </div>
            </div>
          </el-form-item>

          <el-form-item prop="password">
            <div class="psd">
              <div class="img">
                <img src="" alt="">
              </div>
              <div class="input">
                <el-input
                  ref="username"
                  v-model="loginForm.mobile"
                  placeholder="Username"
                  name="username"
                  type="password"
                  tabindex="1"
                  auto-complete="on"
                  show-password
                />
              </div>
            </div>
          </el-form-item>
          <div class="check-box">
            <el-checkbox v-model="loginForm.checked">记住密码</el-checkbox>
          </div>
          <div class="loginBtn">
            <el-button
              type="primary"
              style="width: 100%; margin-bottom: 30px"
              @click.native.prevent="handleLogin"
            >立即登录</el-button>
          </div>
        </el-form>
      </div>
      <div class="login-right">
        111
      </div>
    </div>
  </div>
</template>

<script>
export default {
  name: 'Login',
  data() {
    return {
      loginForm: {
        mobile: 'admin',
        password: '111111',
        checked: false
      },
      loginRules: {
      },
      passwordType: 'password',
      redirect: undefined
    }
  },
  watch: {
    $route: {
      handler: function(route) {
        this.redirect = route.query && route.query.redirect
      },
      immediate: true
    }
  },
  methods: {
    showPwd() {
      if (this.passwordType === 'password') {
        this.passwordType = ''
      } else {
        this.passwordType = 'password'
      }
      this.$nextTick(() => {
        this.$refs.password.focus()
      })
    },
    // 点击登录执行的方法
    handleLogin() {
      this.$router.push({ name: 'Dashboard' })
    }
  }
}
</script>

<style lang="scss">
// 全局生效的样式
/* 修复input 背景不协调 和光标变色 */
/* Detail see https://github.com/PanJiaChen/vue-element-admin/pull/927 */

$bg: #283443;
// $light_gray: #68b0fe;
$cursor: #666;

@supports (-webkit-mask: none) and (not (cater-color: $cursor)) {
  .login-container .el-input input {
    color: $cursor;
  }
}

/* reset element-ui css */
.login-container {
  .el-input {
    width: 230px;
    height: 50px;
    background-color: #f8f5f5;
    border: 1px solid #f8f5f5;
    border-radius: 6px;
    border-bottom-left-radius: 0;
    border-top-left-radius: 0;
    &:hover{
      border: #666 1px solid;
    }
    input {
      font-size: 14px;
      background: transparent;
      -webkit-appearance: none;
      padding: 12px 5px 12px 15px;
      color: #000;
      height: 47px;
      caret-color: $cursor;
      font-weight: 400;
      border: 1px solid #f8f5f5;
      &:-webkit-autofill {
        // box-shadow: 0 0 0px 1000px $bg inset !important;
        -webkit-text-fill-color: $cursor !important;
      }
    }
  }

  .el-form-item {
    border: 1px solid rgba(255, 255, 255, 0.1);
    background: rgba(255, 255, 255, 0.7); // 输入登录表单的背景色
    border-radius: 5px;
    color: #454545;
    margin-bottom: 22px;
    display: flex;
    // height: 100px;
    .el-form-item__content{
    flex: 1;
    .img{
    width: 50px;
    height: 50px;
    background: #eae7e7;
    border-radius: 8px 0 0 8px;
    }
    }
  }

  .el-form-item__error {
    color: #fff;
  }
}
</style>

<style lang="scss" scoped>
// 只对当前组件生效的样式
$bg: #2d3a4b;
$dark_gray: #889aa4;
$light_gray: #eee;

.login-container {
  min-height: 100%;
  width: 100%;
  background-color: $bg;
  overflow: hidden;
  background-color: #fff;
  .login-content{
    display: flex;
    width: 958px;
    height: 516px;
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    box-shadow: rgb(93 93 93 / 33%) 0px 0px 20px;
    background-color: rgb(255, 255, 255);
    border-radius: 40px;
    .login-left{
    width: 398px;
    height: 516px;
    background: rgb(255, 255, 255);
    border-radius: 34px 0px 0px 34px;
    margin: 0px auto;
    .user{
      display: flex;
      margin-top: 50px;
    margin-left: 59px;
    width: 280px;
    height: 50px;
    }
    .psd{
      display: flex;
      margin-left: 59px;
    width: 280px;
    height: 50px;
    margin-top: 22px;
    }
    .login-title{
      margin-left: 124px;
    margin-top: 72px;
    img{
      width: 150px;
    height: 64px;
    }
    }
    }
    .login-right{
      flex: 1;
    }
  }
  .check-box{
    margin-top: 22px;
    margin-left: 60px;
  }
  .loginBtn {
    margin-top: 23px;
    margin-left: 59px;
    width: 280px;
    .el-button{
    height: 50px;
    border-radius: 8px;
    box-shadow: 0 2px 9px 1px rgb(255 178 0 / 47%);
    font-size: 16px;
    font-weight: 600;
    text-align: center;
    color: #332929;
    line-height: 22px;
    }
  }

  // .tips {
  //   font-size: 14px;
  //   color: #fff;
  //   margin-bottom: 10px;

  //   span {
  //     &:first-of-type {
  //       margin-right: 16px;
  //     }
  //   }
  // }

  // .svg-container {
  //   padding: 6px 5px 6px 15px;
  //   color: $dark_gray;
  //   vertical-align: middle;
  //   width: 30px;
  //   display: inline-block;
  // }

  // .title-container {
  //   position: relative;

  //   .title {
  //     font-size: 26px;
  //     color: $light_gray;
  //     margin: 0px auto 40px auto;
  //     text-align: center;
  //     font-weight: bold;
  //   }
  // }

  // .show-pwd {
  //   position: absolute;
  //   right: 10px;
  //   top: 7px;
  //   font-size: 16px;
  //   color: $dark_gray;
  //   cursor: pointer;
  //   user-select: none;
  // }
}
</style>
